home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Video Toaster 4.0
/
Video Toaster v4.0.iso
/
arexx
/
modeler
/
makemotion.lwm
< prev
next >
Wrap
Text File
|
1993-12-13
|
4KB
|
172 lines
/* CMD: Make Motion
* Create motion file with user-specified functions of t in each channel
* By Arnie Cachelin © 1993 NewTek Inc.
* Tue Jun 22 01:34:00 1993
*/
NUMERIC DIGITS 6
call addlib "LWModelerARexx.port", 0
signal on error
signal on syntax
call addlib "rexxsupport.library", 0, -30, 0
MATHLIB="rexxmathlib.library"
IF POS(MATHLIB , SHOW('L')) = 0 THEN
IF ~ADDLIB(MATHLIB , 0 , -30 , 0) THEN DO
call notify(1,"!Can't find "MATHLIB)
exit
END
MFile=getfilename("-- Save Motion --","t:")
if MFile ~="(none)" then File.Name=MFile
else exit
say file.name
sysnam = 'Motion: 'MFile
filnam = 'ENV:Motion.state'
version = 'Motion Maker v1.0'
Frames=30
h=0; p=0; b=0
xsc=1; ysc=1; zsc=1
File.type="LWMO"
SecsPerFrame=1/30
Time=SecsPerFrame*Frames
dt=SecsPerFrame
/* Default Motion functions */
FofT.0.0 = "2*t"
FofT.0.1 = "4*sin(360*t)" /* 1hz sine wave */
FofT.0.2 = "0"
FofT.1.0 = "t*90" /* 90 degrees/sec (0.25hz) */
FofT.1.1 = "90"
FofT.1.2 = "(120*t)//60"
FofT.2.0 = "1"
FofT.2.1 = "1 + 0.2*cos(360*t)" /* 1hz cosine wave */
FofT.2.2 = "1 + 0.1*randu()" /* random fluctuation 10% */
if (exists(filnam)) then do
if (~open(state, filnam, 'R')) then break
if (readln(state) ~= version) then break
parse value readln(state) with frames keyspacing .
do ch=0 to 2
do i=0 to 2
FofT.ch.i = readln(state)
end i
end ch
call close state
end
call req_begin sysnam
id_mes = req_addcontrol("Make ", 'T', "motion for LW, using your own f(t)")
id_keysp = req_addcontrol("Key Spacing", 'n')
id_frames = req_addcontrol("Frames ", 'n',0)
id_ch.0.0 = req_addcontrol(" X ", 'S',40)
id_ch.0.1 = req_addcontrol(" Y ", 'S',40)
id_ch.0.2 = req_addcontrol(" Z ", 'S',40)
id_ch.1.0 = req_addcontrol(" H ", 'S',40)
id_ch.1.1 = req_addcontrol(" P ", 'S',40)
id_ch.1.2 = req_addcontrol(" B ", 'S',40)
id_ch.2.0 = req_addcontrol("ScX", 'S',40)
id_ch.2.1 = req_addcontrol("ScY", 'S',40)
id_ch.2.2 = req_addcontrol("ScZ", 'S',40)
call req_setval id_frames, Frames
call req_setval id_Keysp, 5
do ch=0 to 2
do i=0 to 2
say ch i FofT.ch.i
call req_setval id_ch.ch.i, FofT.ch.i
end i
end ch
if (~req_post()) then do
call req_end
exit
end
frames = req_getval(id_frames) % 1
KeySpacing = req_getval(id_keysp)
do ch=0 to 2
do i=0 to 2
FofT.ch.i = req_getval(id_ch.ch.i)
end i
end ch
call req_end
if (open(state, filnam, 'W')) then do
call writeln state, version
call writeln state, frames keyspacing
do ch=0 to 2
do i=0 to 2
call writeln state, FofT.ch.i
end i
end ch
call close state
end
Time=SecsPerFrame*Frames
Keys=1+Frames%KeySpacing
frame=0
call meter_begin frames+2, 'Generating Motion'
call WriteHeader(mot,keys)
t=0
do frame=0 to frames
do ch=0 to 2
do i=0 to 2
say 'Val='||FofT.ch.i
interpret 'Val='||FofT.ch.i
chan.ch.i = Val
end i
end ch
if frame//KeySpacing=0 then
call WriteKey(mot,frame,1)
else if frame=Frames then
call WriteKey(mot,frame,1)
t=t+dt
call meter_step
end
call close mot
call meter_end
call notify(1,'!Created LightWave Motion File: 'File.name)
exit
WriteKey: PROCEDURE EXPOSE chan.
arg MotFile, frame, lin
channels=""
do ch=0 to 2
do i=0 to 2
channels= channels||' '||chan.ch.i
end i
end ch
spline=frame lin "0.0 0.0 0.0"
say channels spline
call writeln(MotFile,channels)
call writeln(MotFile,spline)
return frame
WriteHeader: PROCEDURE EXPOSE File.
arg MotFile, Keys
if open(MotFile,File.name,'W') then do
call writeln(MotFile,File.type)
call writeln(MotFile,"1") /* magic # */
call writeln(MotFile,"9") /* Channels */
call writeln(MotFile,Keys)
end
else do
Bummer("Can't open Motion file : "File.name)
end
return 1
Bummer:
ARG etxt
t=Notify(1,'!Rexx Script Error','@'ETxt)
exit
syntax:
error:
call end_all
t=Notify(1,'!Rexx Script Error','@'ErrorText(rc),'Line 'SIGL)
exit